<?php
class Backoffice_FlipperController extends CC_Controller
{
    /**
     * List all the flippers in a paginated list
     * 
     * URL: /backoffice/flipper/index
     */
    public function indexAction()
    {
        // DQL to list and paginate flippers
        $dql = $this->_em->createQuery('SELECT f FROM CC\Entity\Flipper f JOIN f.group g JOIN f.flag fl JOIN f.privilege p ORDER BY fl.name ASC, g.name ASC, p.name ASC');
        
        $flippers = new Zend_Paginator(new DoctrineExtensions\Paginate\PaginationAdapter($dql));
        $flippers->setCurrentPageNumber($this->_getPage())
                 ->setItemCountPerPage(20)
                 ->setPageRange(10);
        
        $this->view->flippers = $flippers;
    }
}
?>